#include "StdAfx.h"
#include "CSegment2D.h"
#include "math.h"

CSegment2D::CSegment2D(void){

		setPi(0,0);
		setPd(0,0);

}

CSegment2D::CSegment2D(int xi, int xd, int yi, int yd){

	setPi(xi,yi);
	setPd(xd,yd);
}


CSegment2D::CSegment2D(const CSegment2D &s){

	set(s.getPi(),s.getPd());

}


CSegment2D::~CSegment2D(void){
}

CSegment2D::CSegment2D(Cpunt2D Pi, Cpunt2D Pd){

	setPi(Pi);
	setPd(Pd);
}


Cpunt2D CSegment2D::getPi() const{

	return m_pi;

}

Cpunt2D CSegment2D::getPd() const{

	return m_pd;
}


void CSegment2D::get(Cpunt2D &Pi, Cpunt2D &Pd)const{

	Pi=m_pi;
	Pd=m_pd;

}


float CSegment2D::getlong()const{


	int c1=m_pi.GetX()-m_pd.GetX();
	int c2=m_pi.GetY()-m_pd.GetY();
	return sqrt(double (c1*c1+c2*c2));

}


void CSegment2D::getPi(int &xi, int &yi) const{

	xi=m_pi.GetX();
	yi=m_pi.GetY();
}

void CSegment2D::getPd(int &xd, int &yd) const{

	xd=m_pd.GetX();
	yd=m_pd.GetY();

}

void CSegment2D::setPi(int xi, int yi){

	m_pi.Set(xi,yi);
}

void CSegment2D::setPd(int xd, int yd){

	m_pd.Set(xd,yd);

}

void CSegment2D::setPi(const Cpunt2D Pi){

	m_pi=Pi;
}

void CSegment2D::setPd(const Cpunt2D Pd){

	m_pd=Pd;

}

void CSegment2D::set(const Cpunt2D Pi, const Cpunt2D Pd){

	setPi(Pi);
	setPd(Pd);

}


CSegment2D CSegment2D::operator =(const CSegment2D &s){

	setPi(s.getPi());
	setPd(s.getPd());

	return *this;
}